﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using System.ComponentModel;
using TMDT_ProjGroup09_Client.LogisticSystemWS;
using System.Collections;

namespace TMDT_ProjGroup09_Client.Pages
{
    public partial class DanhSachChiNhanh : System.Web.UI.Page
    { 
        LogisticSystemWS.LogisticSystemSoapClient ws = new LogisticSystemWS.LogisticSystemSoapClient();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (IsPostBack == false)
            {
                ShowChiNhanh();
            }

           

            
        }

        public void ShowChiNhanh()
        {
            ChiNhanhDTO[] ob = ws.ListDsChiNhanh();

            //------------dung cho 2 phan tu
            //ArrayList arrList = new ArrayList();

            //for (int i = 0; i < ob.Length; i++)
            //{

            //    arrList.Add(new ListItem(ob[i].MaChiNhanh.ToString(), ob[i].TenChiNhanh));

            //}
          
            GridView1.DataSource = ConvertType(ob);
            GridView1.DataBind();
        }

        public DataTable ConvertType(ChiNhanhDTO[] ob)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("ID", Type.GetType("System.String"));

            dt.Columns.Add("Tên Chi Nhánh", Type.GetType("System.String"));

            dt.Columns.Add("Địa Chỉ", Type.GetType("System.String"));

            dt.Columns.Add("Ghi Chú", Type.GetType("System.String"));

            for (int i = 0; i < ob.Length; i++)
            {

                dt.Rows.Add();

                dt.Rows[dt.Rows.Count - 1]["ID"] = ob[i].MaChiNhanh.ToString();

                dt.Rows[dt.Rows.Count - 1]["Tên Chi Nhánh"] = ob[i].TenChiNhanh;

                dt.Rows[dt.Rows.Count - 1]["Địa Chỉ"] = ob[i].DiaChi;

                dt.Rows[dt.Rows.Count - 1]["Ghi Chú"] = ob[i].GhiChu;

            }
            return dt;
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}